class FtpReplication
  include StorageSystem
  
  def self.put(fetcher)
    replica_system = fetcher.replica_system
    main_replica = fetcher.main_replica
    
    # 1. Connect to FTP server
    ftp_handler = if replica_system.require_authentication?
        FtpStorage.new(replica_system.hostname, replica_system.username, replica_system.password)
      else
        FtpStorage.new(replica_system.hostname)
      end

    # 2. replicate file
    begin
      replica_system.has_internal_uri? ? 
        ftp_handler.put(main_replica.replica_asset_uri, ReplicaSystem.main_repository_path, replica_system.internal_uri) :
        ftp_handler.put(main_replica.replica_asset_uri, ReplicaSystem.main_repository_path)
    rescue FileNotStoredException
      # Problem to upload file into FTP Server
      raise FileNotStoredException.new
    end
  end
  
  def self.get
  end
end